//绘图类
var fw_draw2 = function(canvas, param){
	var vml = Fw.getparam(param, "fillcolor", "strokecolor", "strokeweight");
	var wh = Fw.getparam(param,"width", "height");
	if(Fw.iscanvas){
		if(canvas.obj.tagName.toLowerCase()!="canvas"){
			canvas = canvas.append("canvas").attr(wh);
		}
		var ctx = canvas.obj.getContext("2d");
		ctx.clearRect(0,0,canvas.obj.width,canvas.obj.height);
		canvas.attr(wh);
		ctx.fillStyle = vml.fillcolor;
		ctx.storkeStyle = vml.storkecolor;
		ctx.lineWidth = vml.strokeweight;
		ctx.beginPath();
		switch(param.tp){
			case "rectangle":
				ctx.fillRect(0, 0, param.width, param.height);
				break;
			case "circle":
				var radius = Math.round(param.width/2);
				ctx.arc(radius, radius, radius, 0, Math.PI*2, false);
				ctx.fill();			
				break;
			case "trapezoid":
				ctx.moveTo(param.x1, param.y1);
				ctx.lineTo(param.x2, param.y2);
				ctx.lineTo(param.x3, param.y3);
				ctx.lineTo(param.x4, param.y4);
				ctx.fill();
				ctx.closePath();
				break;
			case "line":
				ctx.moveTo(param.x1, param.y1);
				if(param.lineType==1){
					ctx.lineTo(param.x1, param.y2);
				}else if(param.lineType==2){
					ctx.lineTo(param.x2, param.y1);
				}
				ctx.lineTo(param.x2, param.y2);
				break;
		}
		ctx.stroke();
		//ctx.scale(1,1);
	}else{
		if(param.vml.indexOf(canvas.obj.tagName.toLowerCase())==-1){
			canvas = canvas.append(param.vml).css(wh);	//vml没有width和height属性
		}
		switch(param.tp){
			case "trapezoid":
				canvas.attr("path","m"+param.x1+","+param.y1+"l"+[param.x2,+param.y2,param.x3,param.y3,param.x4,param.y4].join(",")+"xe");
				canvas.attr("coordsize",wh.width+","+wh.height);	
				break;
			case "line":
				wh = {width:Math.abs(param.x2-param.x1),height:Math.abs(param.y2-param.y1)};
				canvas.css(wh);			
				//canvas.attr("from",param.x1+","+param.y1).attr("to",param.x2+","+param.y2);
				var pos;
				if(param.lineType==0){
					pos = [param.x2-param.x1,param.y2-param.y1];
				}else if(param.lineType==1){
					pos = [0,param.y2-param.y1,param.x2-param.x1,param.y2-param.y1];
				}else if(param.lineType==2){
					pos = [param.x2-param.x1,0,param.x2-param.x1,param.y2-param.y1];
				}
				canvas.attr({path:"m0,0l"+pos.join(",")+"e",filled:"f"}).css({position:"absolute",x:param.x1,y:param.y1});
				canvas.attr("coordsize",wh.width+","+wh.height);			
				break;
		}
		canvas.attr(vml);
	}
	return canvas;
};